<%--
  Author: lwx
  Date: 2021/05/08
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引入核心标签库--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <title>Insert title here</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/">
    <link rel="stylesheet" href="css/table.css">
    <link rel="stylesheet" href="css/main.css">
</head>
<body>
<div class="daohang">
    <div class="left"><a>登录成功！你的名字：</a><a href="userinfoupdate.jsp">${user.username}</a></div>
    <div class="right">
        <ul class="daohang_ul">
            <li><a href="">欢迎页</a></li>
            <li><a href="stu/list">管理页</a>
            <li><a href="404.jsp">新功能</a></li>
            <li><a href="exit">退出系统</a></li>
        </ul>
    </div>
</div>
<br>
<table width="800" border="1" align="center">

    <div align="center">
        <h2>学生信息列表</h2>
    </div>
    <div class="adddiv">
        <button class="addbtn" onclick="location.href='studentinfo.jsp'">新增信息</button>

        <span class="searchSpan" id="searchSpan">
        <input id="input_search" class="input_search" name="input_search" type="text" placeholder="search"/>
        <button class="addbtn" onclick="queryByName()">查询</button>
        </span>
    </div>
    <thead>
    <tr>
        <th>id</th>
        <th>姓名</th>
        <th>班级</th>
        <th>学号</th>
        <th>学院</th>
        <th>性别</th>
        <th>详情</th>
        <th>修改</th>
        <th>删除</th>
    </tr>
    </thead>
    <c:forEach items="${studentInfoList}" var="student">
        <tr>
            <td><c:out value="${student.id}"></c:out></td>
            <td><c:out value="${student.sName}"></c:out></td>
            <td><c:out value="${student.sClass}"></c:out></td>
            <td><c:out value="${student.sNo}"></c:out></td>
            <td><c:out value="${student.sCollege}"></c:out></td>
            <td><c:out value="${student.sSex}"></c:out></td>
            <td><a href="stu/detail?type=detail&id=${student.id}">详情</a></td>
            <td><a href="stu/detail?type=modify&id=${student.id}">修改</a></td>
            <td><a href="javascript:void(0)" onclick="del(${student.id})">删除</a></td>
        </tr>
    </c:forEach>
</table>
</body>
<script type="text/javascript">

    var search = document.getElementById('input_search');
    function del(id){
        var ok = window.confirm("确定删除吗？");
        if(ok){
            /*注意：html的base标签可能对JS代码不起作用 */
            document.location.href = "${pageContext.request.contextPath}/stu/del?id=" + id;
        }
    }
    function queryByName(){
        document.location.href = "${pageContext.request.contextPath}/stu/query?sName=" + search.value;
    }
</script>
</html>
